package jdkrel._reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class _MethodDemo {

    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {
        Class<_ReflectObject> reflectObjectClass = _ReflectObject.class;
        //有参构造器
        Constructor<_ReflectObject> constructor1 = reflectObjectClass.getDeclaredConstructor(String.class,Integer.class);
        //对象
        _ReflectObject reflectObject = constructor1.newInstance("1",2);
        //方法
        Method testMethod = reflectObjectClass.getDeclaredMethod("test", String.class);
        //调用方法
        testMethod.invoke(reflectObject, "1");
    }
}
